<template>
	<view class="c-wrap">
		<view class="item" v-for="(item, index) in navList" :key="index" @click="onNavTap(index)">
			<view class="item-icon">
				<image v-if="navindex == index" :src="item.icon2" :style="index == 2 ? 'width: 34rpx' : ''"></image>
				<image v-else :src="item.icon" :style="index == 2 ? 'width: 34rpx' : ''"></image>
			</view>
			<text :class="{active: navindex == index}">{{item.name}}</text>
		</view>
	</view>
</template>

<script>
	export default {
		props: ['navindex'],
		data() {
			return {
				navIndex: 0,
				navList: [{
					name: '首页推荐',
					icon: '../../static/images/icon-store-home.png',
					icon2: '../../static/images/icon-store-home-active.png',
					pageUrl: '/pages/shopInfo/storeIndex'
				}, {
					name: '全部商品',
					icon: '../../static/images/icon-store-goods.png',
					icon2: '../../static/images/icon-store-goods-active.png',
					pageUrl: '/pages/shopInfo/storeGoodsList'
				}, {
					name: '店铺动态',
					icon: '../../static/images/icon-store-msg.png',
					icon2: '../../static/images/icon-store-msg-active.png',
					pageUrl: '/pages/shopInfo/dynamicList'
				}, {
					name: '商品分类',
					icon: '../../static/images/icon-store-cate.png',
					icon2: '../../static/images/icon-store-cate-active.png',
					pageUrl: '/pages/shopInfo/goodsClass'
				}]
			}
		},
		onLoad(options) {
			// this.navIndex = 
		},
		methods: {
			onNavTap(index) {
				// this.navIndex = index
				uni.redirectTo({
					url: this.navList[index].pageUrl
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.c-wrap {
		display: flex;
		padding-left: 20rpx;
		padding-right: 20rpx;
		background-color: #fff;
	}

	.item {
		flex: 1;
		height: 100rpx;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

		text {
			margin-top: 9rpx;
			font-size: 20rpx;
			color: #999;
		}

		.active {
			color: #FF7733;
		}
	}

	.item-icon {
		position: relative;
		width: 38rpx;
		height: 38rpx;

		image {
			position: absolute;
			left: 0;
			top: 0;
			width: 38rpx;
			height: 38rpx;
		}
	}
</style>
